package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.JobJhrMaintain;
import com.ruoyi.system.mapper.JobJhrMaintainMapper;
import com.ruoyi.system.service.JobJhrMaintainService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * jhr控制措施维护(JobJhrMaintain)表服务实现类
 *
 * @author makejava
 * @since 2022-11-23 09:20:09
 */
@Service("jobJhrMaintainService")
public class JobJhrMaintainServiceImpl implements JobJhrMaintainService {
    @Resource
    private JobJhrMaintainMapper jobJhrMaintainDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JobJhrMaintain queryById(Integer id) {
        return this.jobJhrMaintainDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param jobJhrMaintain 筛选条件
     * @param pageRequest    分页对象
     * @return 查询结果
     */
    @Override
    public Page<JobJhrMaintain> queryByPage(JobJhrMaintain jobJhrMaintain, PageRequest pageRequest) {
        long total = this.jobJhrMaintainDao.count(jobJhrMaintain);
        return new PageImpl<>(this.jobJhrMaintainDao.queryAllByLimit(jobJhrMaintain, pageRequest), pageRequest, total);
    }

    @Override
    public List<JobJhrMaintain> queryAll(JobJhrMaintain jobJhrMaintain) {
        return jobJhrMaintainDao.queryAll(jobJhrMaintain);
    }

    /**
     * 新增数据
     *
     * @param jobJhrMaintain 实例对象
     * @return 实例对象
     */
    @Override
    public JobJhrMaintain insert(JobJhrMaintain jobJhrMaintain) {
        this.jobJhrMaintainDao.insert(jobJhrMaintain);
        return jobJhrMaintain;
    }

    /**
     * 修改数据
     *
     * @param jobJhrMaintain 实例对象
     * @return 实例对象
     */
    @Override
    public JobJhrMaintain update(JobJhrMaintain jobJhrMaintain) {
        this.jobJhrMaintainDao.update(jobJhrMaintain);
        return this.queryById(jobJhrMaintain.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.jobJhrMaintainDao.deleteById(id) > 0;
    }
}
